
package nc.pf.arap.txdj;

import nc.md.data.access.NCObject;
import nc.uap.pf.metadata.FlowBizImpl;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nccloud.arap.util.tool.AllotBillStatus;

public class FlowBizImplForTXDJ extends FlowBizImpl {
        
        public FlowBizImplForTXDJ(NCObject ncobject) {
                super(ncobject);
        }

        public Integer getApproveStatus() {
                Integer retTOCheckState = -1;
                Object objValue = this.getAttributeValue("approvestatus");
                if (objValue == null) {
                        return retTOCheckState;
                } else {
                        Integer uapCheckState = Integer.parseInt(objValue.toString());
                        if (AllotBillStatus.FREE.equalsValue(uapCheckState)) {
                                retTOCheckState = -1;
                        } else if (AllotBillStatus.COMMIT.equalsValue(uapCheckState)) {
                                retTOCheckState = 3;
                        } else if (AllotBillStatus.APPROVED.equalsValue(uapCheckState)) {
                                retTOCheckState = 1;
                        } else if (AllotBillStatus.NOPASS.equalsValue(uapCheckState)) {
                                retTOCheckState = 0;
                        }

                        return retTOCheckState;
                }
        }

        public void setApproveDate(UFDateTime approveDate) {
                UFDate date = null;
                if (null != approveDate) {
                        date = approveDate.getDate();
                }

                this.setAttributeValue("approvedate", date);
        }

        public void setApproveStatus(Integer checkState) {
                Integer icheckState;
                switch (checkState) {
                        case -1 :
                                icheckState = (Integer) AllotBillStatus.FREE.value();
                                break;
                        case 0 :
                                icheckState = (Integer) AllotBillStatus.NOPASS.value();
                                break;
                        case 1 :
                                icheckState = (Integer) AllotBillStatus.APPROVED.value();
                                break;
                        case 2 :
                                icheckState = (Integer) AllotBillStatus.APPROVING.value();
                                break;
                        case 3 :
                                icheckState = (Integer) AllotBillStatus.COMMIT.value();
                                break;
                        default :
                                ExceptionUtils.wrappBusinessException(
                                                NCLangRes4VoTransl.getNCLangRes().getStrByID("4009001_0", "04009001-0055"));
                                return;
                }

                super.setApproveStatus(icheckState);
        }
}
